<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script type="text/javascript" th:inline="javascript">
        $.post({
            // 待载入页面URL地址
            url:"/gsuser",
            dataType:"json",
            success:function(date){
                var html = "";
                var dibu = "";
                console.log(date)
                var list = date.list;
                var atty;
                for (var i = 0;i<list.length;i++){
                    if (list[i].authority==1){
                        atty="管理员";
                    }else{
                        atty="用户";
                    }
                    console.log(list[i])
                    html+="<tr>"+"<td><input type='checkbox' name='' lay-skin='primary'/></td>"+
                        "<td>"+list[i].id+"</td>"+
                        "<td>"+list[i].name+"</td>"+
                        "<td>"+atty+"</td>"+
                        "<td class='td-manage'><a title='查看' href='javascript:;'><i class='layui-icon'>&#xe63c;查看</i></a><a id='del' title='删除' href="+'/user/delete/'+list[i].id+"><i class='layui-icon'>&#xe640;</i>删除</a></td>"+
                        "</tr>"

                }
                $("#tbody").html(html)


                // <a th:href="@{/user/edit/{id}(id=${user.id})}" class="ui button mini pink">编辑</a>
                // <a th:href="@{/user/delete/{id}(id=${user.id})}" class="ui button mini teal">删除</a>-->
            }
        })
    </script>

</head>
<body>
<div class="ui container">
    <div class="ui attached segment">
        <form th:action="@{/user/}" method="post" style="display: inline-block !important;">
            <input type="text" name="name" placeholder="输入用户名查找">
            <input type="submit" value="搜索">
        </form>
        <a href="/employee/addemployee" class="ui button mini teal" style="margin-left: 30px !important;">新增</a>
        <a th:href="@{/user/employee/all}" class="ui button mini teal" style="margin-left: 30px !important;">员工管理</a>
        <a th:href="@{/user/file}" class="ui button mini teal" style="margin-left: 30px !important;">照片上传</a>
        <a th:href="@{/user/login}" class="ui button mini teal" style="margin-left: 30px !important;">登录</a>
    </div>
    <table class="ui celled attached table" style="margin-top: 40px !important;">
        <thead><tr>
            <td><input type='checkbox' name='' lay-skin='primary'/></td>
            <th>id</th>
            <th>用户名</th>
            <th>身份</th>
            <th>操作</th>
        </tr></thead>
        <tbody id="tbody"></tbody>
    </table>
    <div class="ui attached segment" >
        <table class="m-mobile-wide" width="425px">
            <thead></thead>
            <tbody id="fenye">
                        <tr align="center">
                            <td><a th:href="@{/user/(pageNum=${page.pageNum}-1)}"  class="ui button basic mini" th:unless="${page.isFirstPage}">上一页</a></td>
                            <td>
                                第
                                <h8 th:text="${page.pageNum}">2</h8>
                                页/共
                                <h8 th:text="${page.pages}">4</h8>
                                页
                                共
                                <h8 th:text="${page.total}">29</h8>
                                条
                            </td>
                            <td>
                                <form name="pageForm" th:action="@{/user/}" method="get">
                                    <div class="ui mini input ">
                                        <input type="text" class="m-bg" name="pageNum" placeholder="页码" style="width: 50px!important; height: 27.76px!important;" required>
                                        <button type="submit" style="font-size: 11px!important;width: 30px!important; height: 0px!important; border: none;margin: 5px;padding: 0;" class="button mini">
                                            跳转
                                        </button>
                                    </div>
                                </form>
                            </td>
                            <td> &nbsp;</td>
                            <td  style="float: right">
                                <a th:href="@{/user/(pageNum=${page.pageNum}+1)}" class="ui button basic mini " style="float: right;" th:unless="${page.isLastPage}">下一页</a>
                            </td>
                        </tr>
            </tbody>
        </table>
    </div>
    <div class="ui success  message" th:unless="${#strings.isEmpty(message)}">
        <i class="close icon"></i>
        <div class="header">提示：</div>
        <p th:text="${message}"></p>
    </div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<script>
    $(".message .close").on('click',function () {
        $(this).closest(".message")
            .transition("fade");
    })
</script>
</body>
</html>